package com.emapp.lccode.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import com.emapp.lccode.R;
import com.emapp.lccode.base.BaseVBRecycleAdapter;
import com.emapp.lccode.bean.District;
import com.emapp.lccode.databinding.ListitemDistrctPopBinding;

import java.util.ArrayList;

/**
 *
 */
public class PopDistrictAdapter extends BaseVBRecycleAdapter<District, ListitemDistrctPopBinding> {
    private Context mContext;
    int type;

    public PopDistrictAdapter(Context mContext, ArrayList<District> datas, int type) {
        super(datas);
        this.mContext = mContext;
        this.type = type;
    }

    @Override
    protected void onBindingData(BaseViewHolder<ListitemDistrctPopBinding> holder, int position) {
        District infor = datas.get(position);
        if (type == 0) {
            holder.getViewBinding().tvName.setText(infor.getItemLabel());
        } else if (type == 1) {
            holder.getViewBinding().tvName.setText(infor.getItemLabel() );
        } else if (type == 2) {
            holder.getViewBinding().tvName.setText(infor.getItemLabel());
        }

        if (infor.isCheck()) {
            holder.getViewBinding().tvName.setTextColor(mContext.getResources().getColor(R.color.main));
        } else {
            holder.getViewBinding().tvName.setTextColor(mContext.getResources().getColor(R.color.word_black));
        }

//        holder.getViewBinding().getRoot().setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                for (Build d : datas) {
//                    d.setCheck(false);
//                }
//                infor.setCheck(true);
//            }
//        });
    }

    @Override
    protected ListitemDistrctPopBinding onBindingView(ViewGroup viewGroup) {
        ListitemDistrctPopBinding viewBinding = ListitemDistrctPopBinding.inflate(LayoutInflater.from(viewGroup.getContext()), viewGroup, false);
        return viewBinding;
    }

}
